<?php

class m131107_033450_oak extends CDbMigration
{
	public function safeUp()
	{
        $sql = 'CREATE TABLE `{{user_work}}`
                (
                    `id` int PRIMARY KEY AUTO_INCREMENT,
                    `user_id` bigint,
                    `work_id` bigint,
                    `created_at` datetime,
                    `updated_at` datetime,

                    CONSTRAINT FOREIGN KEY (`user_id`) REFERENCES `{{user}}` (`id`),
                    CONSTRAINT FOREIGN KEY (`work_id`) REFERENCES `{{work}}` (`id`)
                )
                ENGINE=InnoDB DEFAULT CHARSET=utf8;';
        
        $this->execute($sql);
	}
    
    public function safeDown()
    {
        return false;
    }
}